# Makefile for NETCONF project
#  
# modules directory
#

ifndef PREFIX
    PREFIX=/usr
endif

############### SOURCE PROFILE ##############################

SUBDIR_NM=modules
SUBDIR_CPP=
YANGDUMP=../target/bin/yangdump

############### TARGET PROFILE ##############################

# copy modules to /usr/share/yuma
TOP_INSTALL=$(DESTDIR)$(PREFIX)/share/yuma
INSTALL_TARGET=$(TOP_INSTALL)/modules

######################### MAKE RULES ######################

all: 

ifdef DEVELOPER
install:
else
install:
	mkdir -p $(INSTALL_TARGET)
	mkdir -p $(INSTALL_TARGET)/netconfcentral
	mkdir -p $(INSTALL_TARGET)/ietf
	mkdir -p $(INSTALL_TARGET)/yang
	mkdir -p $(INSTALL_TARGET)/test
	mkdir -p $(INSTALL_TARGET)/test/pass
	mkdir -p $(INSTALL_TARGET)/test/fail
	cp ietf/*.yang $(INSTALL_TARGET)/ietf
	cp yang/*.yang $(INSTALL_TARGET)/yang
	cp test/pass/*.yang $(INSTALL_TARGET)/test/pass
	cp test/fail/*.yang $(INSTALL_TARGET)/test/fail
	cp netconfcentral/*.yang $(INSTALL_TARGET)/netconfcentral
endif  # DEVELOPER

clean-install:
	rm -rf $(INSTALL_TARGET)/*
	mkdir -p $(INSTALL_TARGET)
	mkdir -p $(INSTALL_TARGET)/ietf
	mkdir -p $(INSTALL_TARGET)/netconfcentral
	mkdir -p $(INSTALL_TARGET)/yang
	mkdir -p $(INSTALL_TARGET)/test
	mkdir -p $(INSTALL_TARGET)/test/pass
	mkdir -p $(INSTALL_TARGET)/test/fail
	cp ietf/*.yang $(INSTALL_TARGET)/ietf
	cp netconfcentral/*.yang $(INSTALL_TARGET)/netconfcentral
	cp yang/*.yang $(INSTALL_TARGET)/yang
	cp test/pass/*.yang $(INSTALL_TARGET)/test/pass
	cp test/fail/*.yang $(INSTALL_TARGET)/test/fail

uninstall:
ifndef DEVELOPER
	rm -rf $(INSTALL_TARGET)
endif

clean:

superclean:

distclean: superclean

MODFORMATS=yin yang xsd sqldb html h c
test:
	mkdir -p $(HOME)/modtest
	rm -rf $(HOME)/modtest/*
	for i in $(MODFORMATS); do\
	    echo "$(YANGDUMP) subtree=ietf subtree=netconfcentral \
	    subtree=yang subtree=test/pass output=$(HOME)/modtest \
	    format=$$i defnames=true log=$(HOME)/modtest/test-$$i.log \
	    log-level=debug";\
	    $(YANGDUMP) subtree=ietf subtree=netconfcentral\
	    subtree=yang subtree=test/pass output=$(HOME)/modtest\
	    format=$$i defnames=true log=$(HOME)/modtest/test-$$i.log\
	    log-level=debug;\
	    echo "grep -i \"internal\" $(HOME)/modtest/test-$$i.log";\
	    grep -i "internal" $(HOME)/modtest/test-$$i.log;\
	    echo "grep \"Segmentation\" $(HOME)/modtest/test-$$i.log";\
	    grep "Segmentation" $(HOME)/modtest/test-$$i.log;\
	    echo "grep \"Error:\" $(HOME)/modtest/test-$$i.log";\
	    grep "Error:" $(HOME)/modtest/test-$$i.log;\
	    echo "done with $$i test";\
	done

.PHONY: all test install clean-install uninstall clean superclean distclean


# prevent the make program from choking on all the symbols
# that get generated from autogenerated make rules
.NOEXPORT:
